#include<string>
#include<vector>
#include<array>
#include<unordered_map>
#include<algorithm>
#include<limits>
class Solution {
public:
    int findRadius(std::vector<int>& houses, std::vector<int>& heaters) {
        std::sort(houses.begin(), houses.end());
        std::sort(heaters.begin(), heaters.end());
        int hon = houses.size();
        int hen = heaters.size();
        int ans = 0;
        for (int l = 0,r=0;l<hon;l++)
        {
            while (r+1<hen)
            {
                
                if (std::abs(houses[l] - heaters[r])<std::abs(houses[l]-heaters[r+1]))
                {
                   
                    break;
                }
                r++;
            }
            ans = std::max(ans,std::abs(houses[l] - heaters[r]));
        }
        return ans;
    }
};
